package com.woniu.controller.operation;

import com.woniu.entity.Result;
import com.woniu.service.IOrderSettlementService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;

@RestController
@RequestMapping("/settle")
@Api(tags = "车辆驶出订单结算")
public class OrderSettlementController {

    @Autowired
    private IOrderSettlementService orderSettlementService;

    //前端发送信息：地磁设备发送地磁id（t_magnet_id）及无车的状态(t_magnet_status)[0:无车]
    @ApiOperation("地磁状态驶出，结算订单")
    @GetMapping("/driveOut/{magnetId}/{magnetStatus}")
    public Result driveOut(@PathVariable long magnetId,@PathVariable String magnetStatus) throws ParseException {
        Result result = orderSettlementService.driveOut(magnetId,magnetStatus);
        return result;
    }

    //前端发送信息：订单id
    @ApiOperation("计算订单当前产生的费用")
    @GetMapping("/{orderId}")
    public Result currentCost(@PathVariable long orderId) throws ParseException {
        Result result = orderSettlementService.currentCost(orderId);
        return result;
    }
}
